import React, { useState, useRef } from 'react'
// 获取子组件的实例，子组件必须是 类组件
function Child () {
  const [count, setCount] = useState(10)
  return (
    <>
      child - { count }
    </>
  )
}
function App() {
  const domRef = useRef()
  const childRef = useRef()
  return (
    <div>
      <div ref = { domRef }>获取DOM节点</div>
      <Child ref = { childRef }/>
      <button onClick = { () => {
        console.log('domRef', domRef)
        console.log('childRef', childRef)
      }}>获取数据</button>
    </div>
  )
}

export default App
